package com.xc.c1

object for1 {

  def main(args: Array[String]): Unit = {
    val begin = 1
    val end = 5

    for (i <- begin to end) {
      println("hxc : " + i)
    }

    val list = List(1, "a", 2, "b")
    for (x <- list) {
      println(x)
    }

    val xx = for (o <- list) yield {
      if (o.isInstanceOf[Int]) o
      else 0
    };
    println("yield:" + xx)


    println("-------------------------------------------------")

    for (i <- 0 to 3; j <- 0 to 3) {
      println(s"i = $i ,j = $j")
    }

    println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    for {i <- 0 to 2
         j <- 0 to 2} {
      println(s"i = $i ,j = $j")
    }

    println("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr")
    for (i <- Range(0, 10, 2)) {
      println("Range i : " + i)
    }

    println("iiiiiiiiiiiiiiiiiiiiiiiiii")
    for (i <- 0 to 10 if i % 2 == 1) {
      println("i = " + i)
    }
  }
}
